#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5+5;

int arr[maxn];
void solve(){
	int n, k;
	cin >> n >> k;
	for (int i=1;i<=n;i++) {
		cin >> arr[i];
	}
	
	sort(arr+1, arr+1+n);
	int cnt = 0;
	for (int i=1;i<=n;i++) {
		if (k > arr[i]) {
			k -= arr[i];
			cnt++;
		} else {
			if (k > (arr[i]+1)/2) {
				cnt++;
			}
			break;
		}
	}
	
	cout << cnt << '\n';
}


signed main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}
